#ifndef SBTOPENGLRENDERWINDOW_H_INCLUDED
#define SBTOPENGLRENDERWINDOW_H_INCLUDED

#include "SbtPrerequisites.h"
#include "SbtOpenGLHeader.h"
#include "SbtRenderWindow.h"
#include "SbtLog.h"

namespace Sbt
{

class SBT_EXPORT OpenGLRenderWindow : public RenderWindow
{
public:
    OpenGLRenderWindow(const String& windowTitle,
        const unsigned windowWidth, 
        const unsigned windowHeight,
        const bool isFullScreen,
        OpenGLRenderer* renderer)
        : RenderWindow(windowTitle, windowWidth, windowHeight, isFullScreen)
        , mRenderer(renderer)
    {
        if (!createWindow())
        {
            SystemLog(Text("Create Render Window Failed!"));
            throw std::runtime_error("Create Render Window Failed!");
        }
        SystemLog(L"Create Render Window Successed!");
        LogStream()<<windowTitle<<Text(" W:")<<windowWidth<<Text(" H:")
            <<windowHeight<<Text(" FullScreen:")<<(isFullScreen?Text("yes"):Text("no"))<<Text("\n");
    }

    static LRESULT CALLBACK mWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        return DefWindowProc(hWnd,uMsg,wParam,lParam);
    }

private:
    bool createWindow();

    bool destroyWindow();

private:
    HDC mHDC;
    HGLRC mHGLRC;
    HWND mHWnd;
    HINSTANCE mHInstance;
    OpenGLRenderer* mRenderer;
};

} // namespace Sbt

#endif // SBTOPENGLRENDERWINDOW_H_INCLUDED